﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Library
{
    public partial class SanPham
    {
        public override string ToString()
        {
            return this.TenSP;
        }

        public static List<SanPham> GetList()
        {
            return DalSanPham.GetList();
        }

        public static List<SanPham> FilterList(String MaLoai, String MaMTT, List<SanPham> lst)
        {
            return DalSanPham.GetListByLoaiSPandMTT(MaLoai, MaMTT, lst);
        }

        public SanPham(int _id, String _masp, String _tensp, String _tenhsx, String _gia, String _hinh, String _mau, String _size, LoaiSanPham _bizlsp, MonTheThao _bizmtt)
        {
            ID = _id;
            MaSP = _masp;
            TenSP = _tensp;
            TenHSX = _tenhsx;
            MaLoai = _bizlsp.MaLoai;
            MaMTT = _bizmtt.MaMTT;
            LoaiSanPham = _bizlsp;
            MonTheThao = _bizmtt;
            DonGia = Convert.ToInt32(_gia);
            HinhAnh = _hinh;
            MauSac = _mau;
            Size = _size;
        }

        public void Add()
        {
            this.ID = DalSanPham.Add(this);
        }

        public bool updated = false;

        public void Update()
        {
            DalSanPham.Update(this);
        }

        public void Delete()
        {
            DalSanPham.Delete(this);
        }
    }
}
